import http from '@/utils/request'
import { base } from '@/config'

// 新人专区模块
const newcomer = {
  // 获取新人专区列表
  getNewGoodsList: params => {
    return http.get(`${base.goods}/newGoods/page`, { params })
  },
  // 删除新人商品
  deleteNewGoods: id => {
    return http.post(`${base.goods}/newGoods/delete/${id}`)
  },
  // 修改推荐状态
  updatedRecommend: ({ id, isRecommend }) => {
    return http.post(`${base.goods}/newGoods/recommendCategory/${id}/${isRecommend}`)
  },
  // 修改上下架状态
  updatedUnloadingState: (id, isState) => {
    return http.post(`${base.goods}/newGoods/state/${id}/${isState}`)
  },
  // 批量上下架
  batchShelf: params => {
    return http.postJson(`${base.goods}/newGoods/batch/enablePlatform`, params)
  },
  // 选择复制商品列表数据
  getCopyPageList: params => {
    return http.get(`${base.goods}/newGoods/copyPage`, { params })
  },
  // 通过ID查询商品详情
  getInfoById: params => {
    return http.get(`${base.goods}/newGoods/getById`, { params })
  },
  // 新增商品
  save: data => {
    return http.postJson(`${base.goods}/newGoods/save`, data)
  },
  // 修改商品数据
  edit: data => {
    return http.postJson(`${base.goods}/newGoods/edit`, data)
  }
}

export default newcomer
